#{extends 'CRUD/layout.html' /}
#{set title:'图书添加' /}
<script type="text/javascript" src="/public/javascripts/jquery-1.6.4.min.js"></script>
<script charset="utf-8" src="/public/javascripts/edit_tools/kindeditor-4.0.1/kindeditor-min.js"></script>
<script charset="utf-8" src="/public/javascripts/edit_tools/kindeditor-4.0.1/lang/zh_CN.js"></script>
<script type="text/javascript" src="/public/javascripts/My97DatePicker/WdatePicker.js" defer="defer"></script>
<script type="text/javascript" src="/public/javascripts/validation.js"></script>

<style type="text/css">
	.number_bg{
		border: 1px solid #EEEEEE;
		margin: 5px 0;
		border-left: none;
		border-right: n
	}
	.number_bg .number{
		width: 280px;
		float: left;
		border-bottom: none;
	}
	.number_bg .data{
		width: 280px;
		float: left;
		border-bottom: none;
	}
</style>
<div id="crudBlank" class="${type.name}">
    <h2 id="crudBlankTitle">添加图书</h2>
    <div class="objectForm">
   	<form enctype="multipart/form-data" accept-charset="utf-8" method="post" action="/bookaction/save">
		<div class="crudField select">
			<label for="object_bookTypeIds">
		        图书分类
		    </label>
		    <span>
				<select sid="bookType1" id="findSel" onchange="select(this)" style="margin-right: -4px;">
					#{set i : 0/}
					#{list list , as:"bookType" }
						<option value="${bookType.id }">${bookType.botName }</option>
						#{set i:i+1 /}
					#{/list}
					#{if i <= 0}
						<option>--无--</option>
					#{/if}
				</select>
			</span>
			<span id="bookType1"></span>
			<input id="bookInp" name="book.bookTypeIds" type="hidden"/>
		    <span class="crudHelp">选择图书的分类</span>
		</div>
		
		<div class="crudField text">
			<label for="object_bookTypeIds">
		        出版社
		    </label>
		    <select name="book.statis" >
		    	<option value="0" selected="selected">在馆</option>
		    	<option value="1">不在馆</option>
		    </select>
		    <span class="crudHelp">选择图书的分类</span>
		</div>
		<div class="crudField number">
			<label for="object_bookTypeIds">
		        图书等级
		    </label>
		    <input type="text" size="5" value="1" name="book.bookgrade" >
		    <span class="crudHelp">数值类型</span>
		</div>
		<!-- 出版社信息 -->
		<div class="crudField text">
			<label for="object_bookTypeIds">
		        出版社
		    </label>
		    <input null="true" type="text" size="50" value="" name="book.pressId" >
		    <span class="crudHelp">选择图书的分类</span>
		</div>
		
		<div class="crudField text">
			<label for="object_bookTypeIds">
		        作者
		    </label>
		    <input null="true" type="text" size="50" value="" name="book.auts" >
		    <span class="crudHelp">多个以,号隔开</span>
		</div>
		<div class="crudField text">
			<label for="object_bookTypeIds">
		        译者
		    </label>
		    <input null="true" type="text" size="50" value="" name="book.auty" >
		    <span class="crudHelp">多个以,号隔开</span>
		</div>
		
		<div class="crudField text">
			<label for="object_bookTypeIds">
		        图书名称
		    </label>
		    <input null="true" type="text" size="50" value="" name="book.booName" >
		    <span class="crudHelp"></span>
		</div>
		<div class="crudField text">
			<label for="object_bookTypeIds">
		        ISBN
		    </label>
		    <input null="true" type="text" size="50" value="" name="book.booIsbn" >
		    <span class="crudHelp">ISBN</span>
		</div>
		<div class="crudField text">
			<label for="object_bookTypeIds">
		        定价
		    </label>
		    <input null="true" type="text" size="50" value="" name="book.price" >
		    <span class="crudHelp">图书标价</span>
		</div>
		<div class="crudField text">
			<label for="object_bookTypeIds">
		        捐赠者
		    </label>
		    <input type="text" size="50" value="" name="book.user" >
		    <span class="crudHelp">当书籍是会员捐赠的时候填写</span>
		</div>
		<div class="crudField text">
			<label for="object_bookTypeIds">
		        条码
		    </label>
		    <input null="true" type="text" size="50" value="" name="book.booBarCode" >
		    <span class="crudHelp">条码</span>
		</div>
		
		<div class="crudField text">
			<label for="object_bookTypeIds">
		        标签
		    </label>
		    <input null="true" type="text" size="50" value="" name="book.booTag" >
		    <span class="crudHelp">多个标签请用,号隔开</span>
		</div>
		<div class="crudField text">
			<label for="object_bookTypeIds">
		        库位
		    </label>
		    <input null="true" type="text" size="50" value="" name="book.booStorehouse" >
		    <span class="crudHelp">选择图书的分类</span>
		</div>
		
		<div class="crudField image_file">
			<label for="object_bookTypeIds">
		        图片
		    </label>
		    <input type="file" name="file" id="object_bookTypeIds">
		    <span class="crudHelp">选择图书的封面,格式为jpg,jpeg,png,gif</span>
		</div>
		
		<fieldset class="number_bg">
			<div class="crudField data">
				<label for="object_bookTypeIds">
			        出版时间
			    </label>
			    <input null="true" type="text" class="Wdate" onClick="WdatePicker({isShowWeek:true,startDate:'%y-%M-01',dateFmt:'yyyy-MM-dd',alwaysUseStartDate:true})" name="book.boo_prti">
			    <span class="crudHelp">yyyy-MM-dd</span>
			</div>
			<div class="crudField data">
				<label for="object_bookTypeIds">
			        上架时间
			    </label>
			    <input null="true" type="text" class="Wdate" onClick="WdatePicker({isShowWeek:true,startDate:'%y-%M-01',dateFmt:'yyyy-MM-dd',alwaysUseStartDate:true})" name="book.booPuti">
			    <span class="crudHelp">yyyy-MM-dd</span>
			</div>
			<div class="crudField data">
				<label for="object_bookTypeIds">
			        印刷时间
			    </label>
			    <input null="true" type="text" class="Wdate" onClick="WdatePicker({isShowWeek:true,startDate:'%y-%M-01',dateFmt:'yyyy-MM-dd',alwaysUseStartDate:true})" name="book.booPrintingTime">
			    <span class="crudHelp">yyyy-MM-dd</span>
			</div>
		</fieldset>
		<!-- 数值区  begin -->
		<fieldset class="number_bg">
			<div class="crudField number">
				<label for="object_bookTypeIds">
			        数量
			    </label>
			    <input type="text" size="5" value="0" name="book.booAmou" >
			    <span class="crudHelp">数值类型</span>
			</div>
			<div class="crudField number">
				<label for="object_bookTypeIds">
			        装帧
			    </label>
			    <input type="text" size="5" value="0" name="book.booZp" >
			    <span class="crudHelp"></span>
			</div>
			<div class="crudField number">
				<label for="object_bookTypeIds">
			        版次
			    </label>
			    <input type="text" size="5" value="0" name="book.booEdit" >
			    <span class="crudHelp"></span>
			</div>
			<div class="crudField number">
				<label for="object_bookTypeIds">
			        印次
			    </label>
			    <input type="text" size="5" value="0" name="book.booImpr" >
			    <span class="crudHelp"></span>
			</div>
			<div class="crudField number">
				<label for="object_bookTypeIds">
			        印张
			    </label>
			    <input type="text" size="5" value="0" name="book.booSeal" >
			    <span class="crudHelp"></span>
			</div>
			<div class="crudField number">
				<label for="object_bookTypeIds">
			        字数
			    </label>
			    <input type="text" size="5" value="0" name="book.booWonu" >
			    <span class="crudHelp"></span>
			</div>
			<div class="crudField number">
				<label for="object_bookTypeIds">
			        页数
			    </label>
			    <input type="text" size="5" value="0" name="book.booPages" >
			    <span class="crudHelp"></span>
			</div>
			<div class="crudField number">
				<label for="object_bookTypeIds">
			        开数
			    </label>
			    <input type="text" size="5" value="0" name="book.booMo" >
			    <span class="crudHelp"></span>
			</div>
			<div class="crudField number">
				<label for="object_bookTypeIds">
			        评论数
			    </label>
			    <input type="text" size="5" value="0" name="book.booPin" >
			    <span class="crudHelp"></span>
			</div>
			
		</fieldset>
		<div style="clear: both;"></div>
		
		<fieldset class="number_bg">
			<!-- 默认参数 -->
			<div class="crudField number">
				<label for="object_bookTypeIds">
			        浏览量
			    </label>
			    <input type="text" size="5" value="0" name="book.booBrow" >
			    <span class="crudHelp">给初始值</span>
			</div>
			<div class="crudField number">
				<label for="object_bookTypeIds">
			        借阅量
			    </label>
			    <input type="text" size="5" value="0" name="book.booBorr" >
			    <span class="crudHelp"></span>
			</div>
			<div class="crudField number">
				<label for="object_bookTypeIds">
			        收藏量
			    </label>
			    <input type="text" size="5" value="0" name="book.booEnsh" >
			    <span class="crudHelp"></span>
			</div>
			<div class="crudField number">
				<label for="object_bookTypeIds">
			        推荐量
			    </label>
			    <input type="text" size="5" value="0" name="book.booReco" >
			    <span class="crudHelp"></span>
			</div>
		</fieldset>
		<!-- 数值区  end -->
		<div style="clear: both;"></div>
		<!--  -->
		
		<div class="crudField crud_Logtext">
			<label for="object_bookTypeIds">
		        图书提纲
		    </label>
		    <textarea style="min-width: 700px;min-height: 500px;" id="booCatalog" name="book.booCatalog">
                	<div style="background: url('/public/indexFile/images/book_11.gif') no-repeat scroll 20px 2px transparent;color: #494949;font-weight: bold;overflow: hidden;padding: 0 0 14px 34px;width: 672px;">编辑推荐</div>
                    <div style="color: #494949;line-height: 15px;margin-left: 34px;overflow: hidden;padding-bottom: 10px;width: 672px;">
                    	
                    	f
                    
                    </div>
                    <div style="background: url('/public/indexFile/images/book_11.gif') no-repeat scroll 20px 2px transparent;color: #494949;font-weight: bold;overflow: hidden;padding: 0 0 14px 34px;width: 672px;">内容提要</div>
                    <div style="color: #494949;line-height: 15px;margin-left: 34px;overflow: hidden;padding-bottom: 10px;width: 672px;">
                    	
                    	f
                    	
                    </div>
                    <div style="background: url('/public/indexFile/images/book_11.gif') no-repeat scroll 20px 2px transparent;color: #494949;font-weight: bold;overflow: hidden;padding: 0 0 14px 34px;width: 672px;">作者简介</div>
                    <div style="color: #494949;line-height: 15px;margin-left: 34px;overflow: hidden;padding-bottom: 10px;width: 672px;">
                    	
                    	f
                    
                    </div>
                    <div style="background: url('/public/indexFile/images/book_11.gif') no-repeat scroll 20px 2px transparent;color: #494949;font-weight: bold;overflow: hidden;padding: 0 0 14px 34px;width: 672px;">目录</div>
                    <div style="color: #494949;line-height: 15px;margin-left: 34px;overflow: hidden;padding-bottom: 10px;width: 672px;">
                    	
                    	f
                    
                    </div>
		    </textarea>
		    <span class="crudHelp">编写时替换"f"</span>
		</div>
		
        <p class="crudButtons">
            <input type="submit" name="_save" value="保存" />
        </p>
        </form>
    </div>
</div>
<script type="text/javascript" defer="defer">
	var editor;
	KindEditor.ready(function(K) {
		editor = K.create('textarea[id="booCatalog"]', {
			resizeType : 2,
			allowPreviewEmoticons : false,
			allowImageUpload : false,
			items : [
				'fontname', 'fontsize','|', 
				'forecolor', 'hilitecolor', 'bold', 'italic', 'underline','removeformat', '|', 
				'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist', 'insertunorderedlist', '|', 
				'emoticons', 'image', 'link','table','map','|',
				'preview','source','fullscreen' ]
		
		});
		
	});
	function editor_add_html(txt){
		// 取得HTML内容
		var htmlX = editor.html();
		// 设置HTML内容
		//editor.html( htmlX + "<br>" + txt );
		//将指定的HTML内容添加到编辑区域的最后位置。
		//editor.appendHtml(txt);
		//插入内容
		editor.insertHtml(txt);
	}
</script>
<script type="text/javascript">
	function select(s){
		var o = $(s);
		var os = o.attr("sid");
		var val = o.val();
		if(o.val() != ""){
			$("#"+os).css("display","");
			$.ajax({
				url:'/controllers/BookTypeaction.ajaxBookType',
				type:'post',
				data:'botId='+o.val(),
				dataType:'json',
				success:function(j){
					var i = Number(os.substr(8,os.length));
					var str = 	'<select sid="bookType'+(i+1)+'" onchange="select(this)">';
						str += 	'<option value="" selected="selected">--请选择--</option>';
					var jf = 0 ;
					$.each(j,function(id,e){
						str += 	'<option value="'+e.botId+'">'+e.botName+'</option>';
						jf ++;
					});
						str += 	'</select>';
						str += 	'<span id="bookType'+(i+1)+'"></span>';
					$("#bookType"+i).html(str);
					
					if(jf <= 0){
						$("select[sid='"+'bookType'+(i+1)+"']").css("display","none");
					}
				}
			});
			val = o.val();
		}else{
			var fs = o.parent().attr("id");
			if(fs != null && fs != ""){
				var fo = $("select[sid='"+fs+"']");
				val = fo.val();
			}
			$("#"+os).css("display","none");
		}
		$("#bookInp").val(val);
	}
	select(document.getElementById("findSel"));
	
</script>